Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pods using the same volume share mount #68

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

garenchan
Copy link
Contributor

@garenchan garenchan commented Jul 7, 2022

What problem are we solving?

Even if multiple pods use the same volume, the driver will fork a child process for each of them to mount the volume. This is wasteful of resources and bad for management.

How are we solving the problem?

The idea is that pods using the same volume need to share a weed mount child process.
We currently solve this problem based on the CSI specification.

  1. When a volume is first used on a node, NodeStageVolume will fork a child process to mount it to host's /var/lib/kubelet/plugins/kubernetes.io/csi/pv/<pvc>/globalmount directory.
  2. Later when other pod uses the volume, NodePublishVolume just needs to create a symbolic link /var/lib/kubelet/pods/<pod>/volumes/kubernetes.io~csi/<pvc>/mount to the /var/lib/kubelet/plugins/kubernetes.io/csi/pv/<pvc>/globalmount directory.
  3. If the pod using the volume on the node is deleted, then NodeUnpublishVolume only needs to delete the corresponding symbolic link /var/lib/kubelet/pods/<pod>/volumes/kubernetes.io~csi/<pvc>/mount.
  4. Finally, when the volume is not used by any pods on the node, NodeUnstageVolume will unmount the volume.

Additionally, according to the specification, we also consider scenarios for handling concurrent calls.
https://github.com/container-storage-interface/spec/blob/master/spec.md#concurrency

Checks

  • I have tested the above scenarios if possible.

@chrislusf
Copy link
Contributor

Thanks for the detailed explanation! The PR looks solid.

@chrislusf chrislusf merged commit ff50c53 into seaweedfs:master Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants